#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 7e4 + 10;
const int M = 1.5e5 + 10;

struct city { int x,y,id; friend bool operator < (city a,city b) { return a.y == b.y ? a.x < b.x : a.y < b.y;}}c[N];
set <city> val[N << 2];
set <city> :: iterator it;
struct mat { int t,l,r,d,u;} a[M];
vec G[N];
int w,h,n,m,dis[N];
bool vis[M];

priority_queue<pii,vector<pii>,greater<pii> > q;

void upd(int pos,int v,int o = 1,int l = 1,int r = w) {
	if(v > 0) val[o].insert(c[pos]) ; else val[o].erase(c[pos]); if(l == r) return; int mid = l + r >> 1;
	if(c[pos].x <= mid) upd(pos,v,o << 1,l,mid); else upd(pos,v,o << 1 | 1,mid + 1,r);
}

vec pot;

void runit(int xl,int xr,int ly,int ry,int t,int o = 1,int l = 1,int r = w) {
	if(xl == l && xr == r) {
		it = val[o].lower_bound( (city){0,ly,0} );
		while(it != val[o].end() && (*it).y <= ry) {
			dis[(*it).id] = t; pot.pb((*it).id);
			for(auto y : G[(*it).id]) q.push(pii(t + a[y].t,y)); 
			it++;
		}
		while(pot.size()) upd(pot.back(),-1),pot.pop_back();
		return;
	}
	int mid = l + r >> 1; if(xr <= mid) runit(xl,xr,ly,ry,t,o << 1,l,mid); else if(xl > mid) runit(xl,xr,ly,ry,t,o << 1 | 1,mid + 1,r);
	else runit(xl,mid,ly,ry,t,o << 1,l,mid) , runit(mid + 1,xr,ly,ry,t,o << 1 | 1,mid + 1,r);
}

int main() {
	n = in,m = in,w = in,h = in; for(int i = 1;i <= n;i++) c[i].x = in,c[i].y = in,c[i].id = i;
	for(int i = 1;i <= m;i++) {G[in].pb(i); a[i].t = in,a[i].l = in,a[i].r = in,a[i].d = in,a[i].u = in;}
	for(int i = 1;i <= n;i++) upd(i,1);
	a[0].t = 0; a[0].l = a[0].r = c[1].x; a[0].d = a[0].u = c[1].y; q.push(pii(0,0));
	while(!q.empty()) {
		int x = q.top().se,t = q.top().fi; if(vis[x]) continue; vis[x] = 1; q.pop();
		runit(a[x].l,a[x].r,a[x].d,a[x].u,t);
	}
	for(int i = 2;i <= n;i++) printf("%d\n",dis[i]);
	return 0;
}
